﻿# -*- coding:utf-8 -*-
#
# склад
#
from django.forms import ModelForm
from sklad.models import Category, Part, Department, Unit, Waybill, Document, DocumentReceipt, DocumentDelivery


class CategoryForm(ModelForm): 

    class Meta:
        model = Category
        exclude = ('user',)
        
#    def __init__(self, author, *args, **kwargs):
#        super(CategoryForm, self).__init__(*args, **kwargs)
#        self.author = author 
        
#    def save(self, commit=True):
#        self.cleaned_data['user'] = self.author
#        return super(CategoryForm, self).save(commit)

class PartForm(ModelForm):

    class Meta:
        model = Part
        exclude = ('user',)
        
#    def __init__(self, author, *args, **kwargs):
#        super(PartForm, self).__init__(*args, **kwargs)
#        self.author = author 
        
#    def save(self, commit=True):
#        self.cleaned_data['user'] = self.author
#        return super(PartForm, self).save(commit)

'''
class DocumentForm(ModelForm):
    class Meta:
        model = Document
        exclude = ('kind', 'user', 'state',)
        
    def __init__(self, author, kind, *args, **kwargs):
        super(DocumentForm, self).__init__(*args, **kwargs)
        self.author = author 
        self.kind = kind
        
    def save(self):
        self.cleaned_data['user'] = self.author
        self.cleaned_data['kind'] = self.kind
        self.cleaned_data['state'] = 'N'
        return super(DocumentForm, self).save()
     
        
class DocumentReceiptForm(ModelForm):
    class Meta:
        model = DocumentReceipt
        exclude = ('document',)
        
    def __init__(self, document, *args, **kwargs):
        super(DocumentReceiptForm, self).__init__(*args, **kwargs)
        self.doc = document
        
    def save(self, commit=True):
        self.cleaned_data['document'] = self.doc
        return super(DocumentReceiptForm, self).save(commit)        
        
        
class DocumentDeliveryForm(ModelForm):
    class Meta:
        model = DocumentDelivery
        exclude = ('document',)
        
    def __init__(self, document, *args, **kwargs):
        super(DocumentDeliveryForm, self).__init__(*args, **kwargs)
        self.doc = document
        
    def save(self, commit=True):
        self.cleaned_data['document'] = self.doc
        return super(DocumentDeliveryForm, self).save(commit)           
'''       

 